package cn.wit.summit.chwan.tools.webview;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.net.Uri;
import android.os.Handler;
import android.util.Log;
import android.webkit.JavascriptInterface;
import android.webkit.WebView;
import android.widget.TextView;

import cn.wit.summit.chwan.R;
import cn.wit.summit.chwan.Stat.StatFactory;
import cn.wit.summit.chwan.models.dto.IntentDataBean;
import cn.wit.summit.chwan.models.dto.ShareBean;
import cn.wit.summit.chwan.models.dto.WebAccountDataBean;
import cn.wit.summit.chwan.ui.activity.SettingActivity;
import cn.wit.summit.chwan.ui.activity.ShareWebActivity;
import cn.wit.summit.chwan.ui.base.MyApplication;
import cn.wit.summit.chwan.utils.APKUtils;
import cn.wit.summit.chwan.utils.AccountBean;
import cn.wit.summit.chwan.utils.AccountUtil;
import cn.wit.summit.chwan.utils.CommonUtil;
import cn.wit.summit.chwan.utils.IntentUtil;
import cn.wit.summit.chwan.utils.JsonMapper;
import cn.wit.summit.chwan.utils.MetaUtils;
import cn.wit.summit.chwan.utils.NetWorkUtils;
import cn.wit.summit.chwan.utils.StringUtils;
import cn.wit.summit.chwan.utils.SystemInfoUtils;
import cn.wit.summit.chwan.utils.ToastUtils;
import cn.wit.summit.chwan.utils.UtilsMy;

public class WebJSPInterfaceMethedBean {
    Activity context;
    private Handler mHandler = new Handler();
    WebView webView;
    private int defaultScreenState = 0;
    WebJsInterface webJsInterface;

    public WebJSPInterfaceMethedBean(Activity context, WebView webView, WebJsInterface webJsInterface) {
        this.context = context;
        this.webView = webView;
        this.webJsInterface = webJsInterface;
    }

    /**
     * 获取IMEI
     *
     * @param
     */
    @JavascriptInterface
    public String getQdId() {
        return MetaUtils.getAd(context);
    }

    /**
     * finish
     *
     * @param
     */
    @JavascriptInterface
    public void finish() {
        context.finish();
    }


    @JavascriptInterface
    public void setData(final String appkey, final String accountdata) {


    }

    @JavascriptInterface
    public String getData(final String appkey) {
        return "";
    }

    @JavascriptInterface
    public void openWeb(String url) {
        IntentUtil.getInstance().goShareWebActivity(context, url);
    }

    @JavascriptInterface
    public void alipay(String data) {
        if (StringUtils.isNotEmpty(data)) {
        }
    }

    @JavascriptInterface
    public String getGameName() {
        try {
            String ss = context.getResources().getString(R.string.app_name);
            return ss;
        } catch (Exception e) {
        }
        return "";
    }

    /**
     * 分享
     *
     * @param
     */
    @JavascriptInterface
    public void shareFromJson(final String json) {
        mHandler.post(new Runnable() {
            public void run() {
                CommonUtil.shareUtil(context, json, 5);
            }
        });
    }

    /**
     * 打开活动
     *
     * @param
     */
    @JavascriptInterface
    public void openAction(final String action, final String id) {
        mHandler.post(new Runnable() {
            public void run() {

            }
        });
    }

    /**
     * 参加活动
     *
     * @param
     */
    @JavascriptInterface
    public void joinAction(final String action, final String id) {

        mHandler.post(new Runnable() {
            public void run() {
            }
        });
    }

    /**
     * 显示分享按钮
     *
     * @param
     */
    @JavascriptInterface
    public void showShareButn(final String json) {
        mHandler.post(new Runnable() {
            public void run() {

            }
        });
    }

    /**
     * 设置标题文字
     *
     * @param
     */
    @JavascriptInterface
    public void setTitle(final String title) {
        mHandler.post(new Runnable() {
            public void run() {
                webJsInterface.setTitleText(title);
            }
        });
    }

    /**
     * 启动游戏
     *
     * @param gid     游戏编号
     * @param cheatID 金手指编号
     */
    @JavascriptInterface
    public void startGame(String gid, String cheatID) {
    }

    /**
     * 下载游戏
     */
    @JavascriptInterface
    public void downloadGame(String downloadTaskJson) {
    }

    /**
     * 下载游戏
     */
    @JavascriptInterface
    public void downloadGameByGameId(String gameId) {
    }

    /**
     * 下载游戏
     */
    @JavascriptInterface
    public void downloadGameByGameIdAndUrl(String gameId, String gameurl) {
    }

    /**
     * 下载游戏
     */
    @JavascriptInterface
    public void downloadGameByGameIdIfNoGame(String gameId) {
    }

    /**
     * 查询当前的版本号
     */
    @JavascriptInterface
    public int getNowVersion() {

        return SystemInfoUtils.getInstance(context).getVersionCode();
    }

    /**
     * 查询游戏当前下载状态
     *
     * @param gid
     * @return -1未下载 0 等待 2正在运行 3暂停 5下载完成 6下载失败 9待更新 10等待 11 待安装
     */
    @JavascriptInterface
    public int inquiryGameStatus(String gid) {
        return 0;
    }

    /**
     * 跳转到游戏详情
     *
     * @param gid
     */
    @JavascriptInterface
    public void goGameDetail(String gid) {
    }

    /**
     * 跳转到指定界面
     *
     * @param json
     */
    @JavascriptInterface
    public void startIntent(final String json) {
        mHandler.post(new Runnable() {
            public void run() {
                try {
                    IntentDataBean intentDateBean = JsonMapper.getInstance().fromJson(json, IntentDataBean.class);
                    IntentUtil.getInstance().intentTo(context, intentDateBean);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    /**
     * 获取登录状态和数据
     *
     * @param
     */
    @JavascriptInterface
    public void getAccount() {
        mHandler.post(new Runnable() {
            public void run() {
                WebAccountDataBean webAccountDataBean = new WebAccountDataBean();
                AccountBean accountBean = AccountUtil.getInstance().getAccountData();
                webAccountDataBean.setAccountBean(accountBean);
                if (accountBean != null) {
                    webAccountDataBean.setHasLogin(true);
                    webView.loadUrl("javascript:papaPutAccountData(" + JsonMapper.getInstance().toJson(webAccountDataBean) + ")");
                } else {
                    IntentUtil.getInstance().goMyAccountLoginActivity(context, 0, 2);
                }
            }
        });


    }

    /**
     * 去登录
     *
     * @param
     */
    @JavascriptInterface
    public void login() {
        mHandler.post(new Runnable() {
            public void run() {
                WebAccountDataBean webAccountDataBean = new WebAccountDataBean();
                AccountBean accountBean = AccountUtil.getInstance().getAccountData();
                webAccountDataBean.setAccountBean(accountBean);
                AccountUtil.getInstance().accountLoginOut(context);

//                startLogling = true;
//                    com.join.mgps.activity.MyAccountCenterActivity_.intent(context).intentFrom(2).fromIndex(0).start();
                IntentUtil.getInstance().goMyAccountLoginActivity(context, 0, 2);

            }
        });
    }

    /**
     * getAccountVer2
     * 获取账户登录状态
     *
     * @param
     */
    @JavascriptInterface
    public String getAccountVer2() {

        WebAccountDataBean webAccountDataBean = new WebAccountDataBean();
        AccountBean accountBean = AccountUtil.getInstance().getAccountData();
        if (accountBean != null) {
            webAccountDataBean.setAccountBean(accountBean);
            webAccountDataBean.setHasLogin(true);
        } else {
            webAccountDataBean.setHasLogin(false);
        }
        String ss = JsonMapper.getInstance().toJson(webAccountDataBean);
        Log.v("sss", ss);
        return JsonMapper.getInstance().toJson(webAccountDataBean);

    }


    /**
     * 分享到指定界面
     *
     * @param
     */
    @JavascriptInterface
    public void shareToOne(final int shareTo, final String json) {
        mHandler.post(new Runnable() {
            public void run() {
                ShareBean shareBean = JsonMapper.getInstance().fromJson(json, ShareBean.class);
                shareBean.setFrom(5);
                CommonUtil.shareToOne(context, shareTo, shareBean);
            }
        });
    }

    /**
     * 当按返回键时返回到指定页面
     *
     * @param
     */
    @JavascriptInterface
    public void goBackUrl(final String url) {
        mHandler.post(new Runnable() {
            public void run() {
                if ("".equals(url)) {
                    finish();
                } else {
                    webView.loadUrl(url);
                }
            }
        });
    }

    /**
     * 获取IMEI
     *
     * @param
     */
    @JavascriptInterface
    public String getIMEI() {
        return SystemInfoUtils.getInstance(context).getDeviceId();
    }

    /**
     * 获取IMEI
     *
     * @param
     */
    @JavascriptInterface
    public String getDeviceId() {
        return SystemInfoUtils.getInstance(context).getDeviceId();
    }

    /**
     * 获取获取手机型号
     *
     * @param
     */
    @JavascriptInterface
    public String getPhoneModle() {
        return SystemInfoUtils.getInstance(context).getMobileMODEL();
    }

    /**
     * 获取获取手机型号
     *
     * @param
     */
    @JavascriptInterface
    public String getVendor() {
        return SystemInfoUtils.getInstance(context).getVendor();
    }

    /**
     * 获取android 版本
     *
     * @param
     */
    @JavascriptInterface
    public String getAndroidVersion() {
        return SystemInfoUtils.getInstance(context).getMobileSystenmVersion();
    }

    /**
     * 获取app版本号1.5.3
     *
     * @param
     */
    @JavascriptInterface
    public String getAppversionName() {
        return SystemInfoUtils.getInstance(context).getVersionName();
    }

    /**
     * 设置屏幕横屏竖屏 0 默认  1横屏 2 竖屏
     *
     * @param
     */
    @JavascriptInterface
    public void setScreenLandOrPort(final int screenLandOrPort) {
        mHandler.post(new Runnable() {
            public void run() {
                switch (screenLandOrPort) {

                    case 0:
                        context.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
                        defaultScreenState = 0;
                        break;
                    case 1:
                        context.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
                        defaultScreenState = 1;
                        break;
                    case 2:
                        context.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
                        defaultScreenState = 2;
                        break;

                }

            }
        });
    }

    /**
     * showOrHide是否显示标题栏不显示为fale  显示为true
     *
     * @param
     */
    @JavascriptInterface
    public void showTitle(final boolean showOrHide) {
        mHandler.post(new Runnable() {
            public void run() {
                webJsInterface.showTitle(showOrHide);
            }
        });
    }

    /**
     * 签到回调
     *
     * @param success true,今日签到成功；false,今日未签到
     */
    @JavascriptInterface
    public void checkin(final boolean success) {
        mHandler.post(new Runnable() {
            public void run() {


            }
        });
    }

    /**
     * 播放视屏
     */
    @JavascriptInterface
    public void playVideo(final String videoUrl, final String imageUrl) {
        mHandler.post(new Runnable() {
            public void run() {

            }
        });
    }

    /**
     * 复制
     */
    @JavascriptInterface
    public void copyToClipboard(final String text) {

        if (StringUtils.isNotEmpty(text)) {
            UtilsMy.copyToClickBoard(context, text);
            ToastUtils.getInstance(context).showToastSystem("复制成功！");
        }
    }

    /**
     * 跳转完善资料  1.7.0+
     */
    @JavascriptInterface
    public void intentToCompletAccount() {
        mHandler.post(new Runnable() {
            public void run() {
                if (MyApplication.accountBean == null) {
                    IntentUtil.getInstance().goLoginActivity(context);
                } else {
                    if(MyApplication.accountBean.getToken()!=null){
                        context.startActivity(new Intent(context, SettingActivity.class));
                    }else{
                        ToastUtils.getInstance(context).showToastSystem("token为空");
                    }
                }
            }
        });
    }

    /**
     * 查询app是否已安装 1.7.1+
     */
    @JavascriptInterface
    public boolean checkAppHasInstall(String packageName) {
        boolean hasInstall = false;
        try {
            hasInstall = APKUtils.getInstance(context).checkInstall(context, packageName);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return hasInstall;
    }

    /**
     * 跳转指定qq号码聊天
     */
    @JavascriptInterface
    public void intentQQ(final String qqNumber) {
        mHandler.post(new Runnable() {
            public void run() {
                try {
                    String url11 = "mqqwpa://im/chat?chat_type=wpa&uin=" + qqNumber + "&version=1";
                    context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url11)));
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    /**
     * 跳转指定qq群聊天
     */
    @JavascriptInterface
    public void intentQQGroup(final String key) {
        mHandler.post(new Runnable() {
            public void run() {

                Intent intent = new Intent();
                intent.setData(Uri.parse("mqqopensdkapi://bizAgent/qm/qr?url=http%3A%2F%2Fqm.qq.com%2Fcgi-bin%2Fqm%2Fqr%3Ffrom%3Dapp%26p%3Dandroid%26k%3D" + key));
                try {
                    context.startActivity(intent);
                } catch (Exception e) {
                    ToastUtils.getInstance(context).showToastSystem(" 未安装手Q或安装的版本不支持");
                }
            }
        });
    }

    /**
     * 分享到指定界面
     *
     * @param shareTo   =0 微信好友 ，=1 //微信朋友圈，=2  //qq，=4//新浪微博     不支持qq空间
     * @param message   分享内容或者 图片地址或者分享内容
     * @param shareType 分享类型 0默认, 1文字 ， 2 图片
     */
    @JavascriptInterface
    public void shareToOneImageOrText(final int shareTo, final String message, final int shareType) {
        mHandler.post(new Runnable() {
            public void run() {
                CommonUtil.shareToOne(context, shareTo, message, shareType, 5);
            }
        });
    }
    /**
     * 分享到指定界面
     *
     * @param shareTo   =0 微信好友 ，=1 //微信朋友圈，=2  //qq，=4//新浪微博     不支持qq空间
     * @param message   分享内容或者 图片地址或者分享内容
     * @param shareType 分享类型 0默认, 1文字 ， 2 图片
     */
    @JavascriptInterface
    public void shareToOneImageOrText(final int shareTo, final String message, final int shareType, final int from, final String fromName, final String gamId) {
        mHandler.post(new Runnable() {
            public void run() {
                StatFactory.getInstance().sendShare(context,gamId,from+"",fromName);
                CommonUtil.shareToOne(context, shareTo, message, shareType, from);
            }
        });
    }

    /**
     * @param payType      支付方式， 0 默认可选支付方式， 1 支付宝， 2 微信， 3银联卡 ，4 信用卡
     * @param callback_url 游戏方回调地址。
     */
    @JavascriptInterface
    public void payByPapa(final String app_key, final int payType, final String callback_url, final String app_name, final String app_order_id, final int paOpenuid, final String uid,
                          final String product_id, final String product_name, final String pay_rmb, final String extra1, final String extra2) {
        mHandler.post(new Runnable() {
            public void run() {
                try {

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    /**
     * 1.7.2+使用
     *
     * @param payType      支付方式， 0 默认可选支付方式， 1 支付宝， 2 微信 汇付宝， 3银联卡 ，4 信用卡 , 5 饭票支付,6 红包支付  7 ,紫微兴  8,威富通
     * @param callback_url 游戏方回调地址。
     * @param payShowType  显示类型  0 默认不显示饭票和红包   ，1 显示饭票，2显示 红包， 3显示饭票和红包
     */
    @JavascriptInterface
    public void payByPapa(final String app_key, final String appPrivateKey, final int payType, final String callback_url, final String app_name, final String app_order_id, final String paOpenuid, final String uid,
                          final String product_id, final String product_name, final String pay_rmb, final String extra1, final String extra2, final String token, final String payShowType) {
        mHandler.post(new Runnable() {
            public void run() {
                try {

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    /**
     * @param payType      充值饭票， 0 默认可选充值方式， 1 支付宝， 2 微信汇付宝， 3银联卡 ，4 信用卡   7 ,紫微兴  8,威富通
     * @param callback_url 游戏方回调地址。
     */
    @JavascriptInterface
    public void rechargePabiFrom(final String app_key, final int payType, final String callback_url, final String app_name, final String app_order_id, final String paOpenuid, final String uid,
                                 final String product_id, final String product_name, final String pay_rmb, final String extra1, final String extra2) {
        mHandler.post(new Runnable() {
            public void run() {
                try {

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    /**
     * @param show 是否显示
     */
    @JavascriptInterface
    public void showRefresh(final boolean show) {
        mHandler.post(new Runnable() {
            public void run() {
//                    if (show) {
//                        refresh.setVisibility(View.VISIBLE);
//                    } else {
//                        refresh.setVisibility(View.GONE);
//                    }
            }
        });
    }

    /**
     * @param show 是否显示
     */
    @JavascriptInterface
    public void showDownload(final boolean show) {
        mHandler.post(new Runnable() {
            public void run() {

            }
        });
    }

    /**
     * @param show 是否显示
     */
    @JavascriptInterface
    public void showSearch(final boolean show) {
        mHandler.post(new Runnable() {
            public void run() {

            }
        });
    }

    /**
     * 跳转个人中心界面
     */
    @JavascriptInterface
    public void goAccountCenter() {
        mHandler.post(new Runnable() {
            public void run() {
                IntentUtil.getInstance().goAccountCenterActivity(context);
            }
        });
    }

    /**
     * 跳转手柄设置界面
     */
    @JavascriptInterface
    public void goHandShark() {
        mHandler.post(new Runnable() {
            public void run() {
            }
        });
    }

    /**
     * 跳转存号箱界面
     */
    @JavascriptInterface
    public void goCodesBoxActivity() {
        mHandler.post(new Runnable() {
            public void run() {
            }
        });
    }

    /**
     * 跳转下载管理界面
     */
    @JavascriptInterface
    public void goDownloadCenter() {
        mHandler.post(new Runnable() {
            public void run() {
            }
        });
    }

    /**
     * 页游或者商城获取OpenUid   和token  如果返回值是""  则认为未4登录等下次获取Uid
     */
    @JavascriptInterface
    public String getPapaUIDAndToken() {
        return "";
    }

    /**
     * 第三方调起下载文件
     */
    @JavascriptInterface
    public void downloadFile(String url, String fileName) {
        UtilsMy.downFileFromWeb(context, url, fileName);
    }

    /**
     * 查询app信息
     */
    @JavascriptInterface
    public String checkAppInfo(String packageName) {
        APKUtils.APKInfo hasInstall = null;
        try {
            hasInstall = APKUtils.getInstance(context).getInstallAPKInfo(context, packageName);
        } catch (Exception e) {
            e.printStackTrace();
        }
        String apkInfoString = "";
        apkInfoString = JsonMapper.getInstance().toJson(hasInstall);
        return apkInfoString;
    }

    /**
     * 关闭 是否显示
     */
    @JavascriptInterface
    public void showFinish(final boolean show) {
        mHandler.post(new Runnable() {
            public void run() {

            }
        });
    }

    /**
     * 返回 是否显示
     */
    @JavascriptInterface
    public void showBackNew(final boolean show) {
        mHandler.post(new Runnable() {
            public void run() {
                if (show) {
                } else {
                }
            }
        });
    }

    /**
     * tost字符串
     */
    @JavascriptInterface
    public void toastText(final String message) {
        mHandler.post(new Runnable() {
            public void run() {
                ToastUtils.getInstance(context).showToastSystem(message);
            }
        });
    }

    /**
     * 保存字符串
     */
    @JavascriptInterface
    public void saveStringByKey(String saveKey, String message) {
        SharedPreferences mSharedPreferences = context.getSharedPreferences("Papa_Stat_SharedPreferences", Context.MODE_PRIVATE);
        SharedPreferences.Editor mEditor = mSharedPreferences.edit();
        mEditor.putString("papaH5_" + saveKey, message);
        mEditor.commit();
    }

    /**
     * 获取字符串
     */
    @JavascriptInterface
    public String getStringByKey(String saveKey) {
        SharedPreferences mSharedPreferences = context.getSharedPreferences("Papa_Stat_SharedPreferences", Context.MODE_PRIVATE);
        String message = mSharedPreferences.getString("papaH5_" + saveKey, "");
        return message;
    }

    /**
     * 读取sdk跳转携带来的数据
     */
    @JavascriptInterface
    public String getSdkIntentData(String appKey) {
        SharedPreferences mSharedPreferences = context.getSharedPreferences("Papa_Stat_SharedPreferences", Context.MODE_PRIVATE);
        String message = mSharedPreferences.getString("papasdk_" + appKey, "");
        return message;
    }

    /**
     * 读取sdk跳转携带来的数据 这个优先
     */
    @JavascriptInterface
    public String getSdkIntentData() {

        return "";
    }

    /**
     * 切换账户
     */
    @JavascriptInterface
    public void changeAccount(String accountJson) {
        try {

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * papa设置vip充值选项
     */
    @JavascriptInterface
    public void creatVipOrder(final int orderType) {
        mHandler.post(new Runnable() {
            public void run() {
                try {
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    /**
     * 更新Vip信息
     */
    @JavascriptInterface
    public void updateVip() {
    }

    /**
     * 检查是否有网络 52+
     */
    @JavascriptInterface
    public int checkNetWork() {
        if (NetWorkUtils.isNetworkConnected(context)) {
            return 1;

        } else {
            return 0;
        }
    }

    /**
     * 跳转开播或者主播中心
     */
    @JavascriptInterface
    public void liveIntentTo(int type) {
//            if (type == 1) {
//                pushLive();
//            } else {
//                IntentUtil.getInstance().goLiverCenterActivity(context);
//            }
    }

    /**
     * 上传头像
     */
    @JavascriptInterface
    public void papaLiveCropImage() {
        mHandler.post(new Runnable() {
            public void run() {
            }
        });
    }

    /**
     * 账户详情
     */
    @JavascriptInterface
    public void goAccountDetial() {
        mHandler.post(new Runnable() {
            public void run() {
            }
        });
    }

    /**
     * 消息
     */
    @JavascriptInterface
    public void goProfileMessage() {
        mHandler.post(new Runnable() {
            public void run() {
                IntentUtil.getInstance().goMessageActivity(context);
            }
        });
    }

    /**
     * 去选择要上传的图片
     */
    @JavascriptInterface
    public void goChoiceUploadImage() {
        mHandler.post(new Runnable() {
            public void run() {
            }
        });
    }

    /**
     * 去直播
     */
    @JavascriptInterface
    public void goStartLive() {
//            mHandler.post(new Runnable() {
//                public void run() {
//                    pushLive();
//                }
//            });
    }

    /**
     * 进入到话题首页界面
     */
    @JavascriptInterface
    public void goMainLabel(final String tag_id) {
        mHandler.post(new Runnable() {
            public void run() {
            }
        });
    }

    /**
     * 进入到话题首页界面
     */
    @JavascriptInterface
    public void goMainLabel(final String tag_id, final String fid, final String fname) {
        mHandler.post(new Runnable() {
            public void run() {
            }
        });
    }

    /**
     * 进入到话题搜索界面
     */
    @JavascriptInterface
    public void goSearchLabel() {
        mHandler.post(new Runnable() {
            public void run() {
            }
        });
    }

    /**
     * 检查是否有直播资源
     */
    @JavascriptInterface
    public int checkLiveRes() {
//            boolean check = checkRes();
//            if (check) {
//                return 1;
//            } else {
//                return 0;
//            }
        return 0;
    }

    /**
     * 显示下载直播弹窗
     */
    @JavascriptInterface
    public void showDownLiveDialog() {
//            mHandler.post(new Runnable() {
//                public void run() {
//                    showDownloadView();
//                }
//            });
    }

    /**
     * 显示下载直播弹窗
     */
    @JavascriptInterface
    public void startGameFromJson(final String json) {
        mHandler.post(new Runnable() {
            public void run() {
                try {

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    @JavascriptInterface
    public void startH5Game(final String downloadTask) {
        try {

        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    @JavascriptInterface
    public String getAllH5game() {
        return "";
    }

    /**
     * 设置为全屏
     */
    @JavascriptInterface
    public void setFullScreenJs(final String json) {
        mHandler.post(new Runnable() {
            public void run() {
                webJsInterface.setFullScreen(true);
            }
        });
    }

    /**
     * 退出全屏
     */
    @JavascriptInterface
    public void setQuitFullScreenJs(final String json) {
        mHandler.post(new Runnable() {
            public void run() {
                webJsInterface.setFullScreen(false);
            }
        });
    }

    /**
     * 赛事跳转入口
     */
    @JavascriptInterface
    public void jumpGameMatch(String romid) {
    }

    @JavascriptInterface
    public void payGameFinish(int resultCode) {
        switch (resultCode) {
            case 1:
                break;

            case 2:

                break;
            default:

                break;
        }
        finish();
    }

   public interface WebJsInterface {
        public void showTitle(boolean showTile);
        public void setTitleText(String titleText);

        public void setFullScreen(boolean showTile);
    }
}